package com.fdb.efp.nls.service.impl;

import com.fdb.efp.nls.service.domain.NlsAlarmNoticeRecord;
import com.fdb.efp.nls.service.domain.TemplateFileUploadRecord;
import com.fdb.efp.nls.service.facade.TemplateFileUploadRecordService;
import com.fdb.efp.nls.service.vo.NlsAlarmNoticeRecordVO;
import com.fdb.efp.nls.service.vo.TemplateFileUploadRecordKeyVO;
import com.fdb.efp.nls.service.vo.TemplateFileUploadRecordVO;
import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.TemplateFileUploadRecordDAO;
import com.fdb.efp.nls.service.domain.TemplateFileUploadRecordKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 需求编号：【2019D0519】
 * 问题编号：【】
 * TODO:模板文件上传记录业务处理类
 * @author xiaojunhui
 * @version 0.1
 * @date 2019/5/18
 */
@Service("templateFileUploadRecordService")
public class TemplateFileUploadRecordServiceImpl implements TemplateFileUploadRecordService, FrameworkService {

    private static Logger logger = LoggerFactory.getLogger(TemplateFileUploadRecordServiceImpl.class);

    @Autowired
    private TemplateFileUploadRecordDAO templateFileUploadRecordDAO;

    @Override
    public int deleteByPrimaryKey(TemplateFileUploadRecordKeyVO key) {
        return this.templateFileUploadRecordDAO.deleteByPrimaryKey(beanCopy(key, new TemplateFileUploadRecordKey()));
    }

    @Override
    public int insert(TemplateFileUploadRecordVO record) {
        return this.templateFileUploadRecordDAO.insert(beanCopy(record, new TemplateFileUploadRecord()));
    }

    @Override
    public int insertBatch(List<TemplateFileUploadRecordVO> records) {

        try {
            return this.templateFileUploadRecordDAO.insertBatch((List<TemplateFileUploadRecord>) beansCopy(records, TemplateFileUploadRecord.class));
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("批量插入记录发生异常："+e.getMessage());
        }
        return 0;
    }
    @Override
    public int insertSelective(TemplateFileUploadRecordVO record) {
        return this.templateFileUploadRecordDAO.insertSelective(beanCopy(record, new TemplateFileUploadRecord()));
    }
    @Override
    public TemplateFileUploadRecordVO selectByPrimaryKey(TemplateFileUploadRecordKeyVO key) {
        TemplateFileUploadRecord templateFileUploadRecord = this.templateFileUploadRecordDAO.selectByPrimaryKey(beanCopy(key, new TemplateFileUploadRecordKey()));
        if (templateFileUploadRecord == null) {
            return null;
        }
        return beanCopy(templateFileUploadRecord, new TemplateFileUploadRecordVO());

    }

    @Override
    public List<TemplateFileUploadRecordVO> selectByBizType(String req,String bizType) {

        List<TemplateFileUploadRecord> list= this.templateFileUploadRecordDAO.selectByBizType(req,bizType);
        try {
            return (List<TemplateFileUploadRecordVO>) beansCopy(list, TemplateFileUploadRecordVO.class);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("转换数据时候发生异常",e);
        }
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(TemplateFileUploadRecordVO record) {
        return this.templateFileUploadRecordDAO.updateByPrimaryKeySelective(beanCopy(record, new TemplateFileUploadRecord()));
    }
    @Override
    public int updateByPrimaryKey(TemplateFileUploadRecordVO record) {
        return this.templateFileUploadRecordDAO.updateByPrimaryKey(beanCopy(record, new TemplateFileUploadRecord()));
    }

    @Override
    public Integer insertNotice(NlsAlarmNoticeRecordVO nlsAlarmNoticeRecord) {
        return this.templateFileUploadRecordDAO.insertNotice(beanCopy(nlsAlarmNoticeRecord, new NlsAlarmNoticeRecord()));
    }
}
